package com.neuedu.web;

import com.neuedu.mapper.RoleTableMapper;
import com.neuedu.pojo.AdminTable;
import com.neuedu.pojo.Result;
import com.neuedu.pojo.RoleTable;
import com.neuedu.service.RoleTableService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/adminToRole")
@Tag(name="管理员管理角色")
public class AdminToRoleController {
    @Resource
    private RoleTableService roleTableService;

    @PostMapping("/addRoleTable")
    public Result<Void> addRoleTable(@RequestBody RoleTable roleTable) {
        return this.roleTableService.addRoleTable(roleTable);
    }

    @GetMapping("/getRoleTables")
    public Result<List<RoleTable>> getRoleTablesByName(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name = "roleName",defaultValue = "")String name) {
        return this.roleTableService.getRoleTables(currentPage,pageSize,name);
    }
    @GetMapping("/getRoles")
    public Result<List<RoleTable>> getRoleTables() {
        return this.roleTableService.getRoleTables();
    }

    @PutMapping("/updateRoleTable")
    public Result<Void> updateRoleTable(@RequestBody RoleTable roleTable) {
        return this.roleTableService.updateRoleTable(roleTable);
    }
    /**
     * 删除
     */
    @DeleteMapping("deleteRoleTable/{id}")
    public Result<Void> deleteRoleTable(@PathVariable("id") Integer id) {
        return this.roleTableService.deleteRoleTable(id);
    }
}
